<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="${contextPath}/staticwx/style/weui.css"/>
    <link rel="stylesheet" href="${contextPath}/staticwx/style/weui2.css"/>
    <link rel="stylesheet" href="${contextPath}/staticwx/style/weui3.css"/>
    <script src="${contextPath}/staticwx/zepto.min.js"></script>
    <script src="${contextPath}/staticwx/updown.js"></script>
    <script src="${contextPath}/staticwx/lazyimg.js"></script>
    <script>

    </script>
    <script>
        $(function(){
            //总页数
            var totalPage=$("#totalPage").val();
            var pageNum = $("#pageNum").val();

            // 每页展示10个
            var pageSize =$("#pageSize").val();

            var mid=$("#mid").val();

            var lv=$("#lv").val();

            $('.weui_panel').dropload({
                scrollArea : window,
                autoLoad : true,//自动加载
                domDown : {//上拉
                    domClass   : 'dropload-down',
                    domRefresh : '<div class="dropload-refresh f15 "><i class="icon icon-20"></i>上拉加载更多</div>',
                    domLoad    : '<div class="dropload-load f15"><span class="weui-loading"></span>正在加载中...</div>',
                    domNoData  : '<div class="dropload-noData">没有更多数据了</div>'
                },
                domUp : {//下拉
                    domClass   : 'dropload-up',
                    domRefresh : '<div class="dropload-refresh"><i class="icon icon-114"></i>上拉加载更多</div>',
                    domUpdate  : '<div class="dropload-load f15"><i class="icon icon-20"></i>释放更新...</div>',
                    domLoad    : '<div class="dropload-load f15"><span class="weui-loading"></span>正在加载中...</div>'
                },
                loadUpFn : function(me){//刷新
                    var result="";
                    $.ajax({
                        type: 'GET',
                        url: '${contextPath}/wx/member/getInferiorListData.htm?mid='+mid+'&lv='+lv+'&pageNum='+pageNum+'&pageSize='+pageSize,
                        dataType: 'json',
                        success: function(data){
                            var json = $.parseJSON(data);
                            if (json.isSuccess == true) {
                                var memberList=json.page;
                                var arrLen = memberList.length;
                                if(arrLen > 0){
                                    for(var i=0; i<arrLen; i++){
                                        var member=memberList[i];
                                        var cdata=new Date(member.createtime);
                                        var url='javascript:void(0);';
                                        if(lv==1){
                                            url='${contextPath}/wx/member/inferiorChildList.htm?pid='+member.id;
                                        }
                                        result+='  <a href="'+url+'" class="weui_media_box weui_media_appmsg">'
                                            +'<div class="weui_media_hd weui-updown">'
                                            +'<img class="weui_media_appmsg_thumb lazyload" src="'+member.headimg+'" alt="" data-img="'+member.headimg+'">'
                                            +'</div>'
                                            +'<div class="weui_media_bd">'
                                            +'<h4 class="weui_media_title">'+member.nickname+'</h4>'
                                            +'<p class="weui_media_desc">'+formatDateTime(cdata)+'</p>'
                                            +'</div>'
                                            +'</a>';
                                    }
                                    $(".weui_panel_bd").html(result);
                                }
                                // 每次数据加载完，必须重置
                                me.resetload();
                                // 重置索引值，重新拼接more.json数据
                                pageNum = 1;
                                // 解锁
                                me.unlock();
                                me.noData(false);
                            }
                        },
                        error: function(xhr, type){
                            //alert('Ajax error!');
                            // 即使加载出错，也得重置
                            me.resetload();
                        }
                    });
                },
                loadDownFn : function(me){//加载更多
                    setTimeout(function () {
                        if (pageNum>=totalPage) {
                            me.lock();
                            me.noData();
                            me.resetload();
                            return;
                        }
                        pageNum++;
                        $("#pageNum").val(pageNum);
                    var result = '';
                    $.ajax({
                        type: 'GET',
                        url: '${contextPath}/wx/member/getInferiorListData.htm?mid='+mid+'&lv='+lv+'&pageNum='+pageNum+'&pageSize='+pageSize,
                        dataType: 'json',
                        success: function(data){
                            var json = $.parseJSON(data);
                            if (json.isSuccess == true) {
                                var memberList=json.page;
                                var arrLen = memberList.length;
                                if(arrLen > 0){
                                    for(var i=0; i<arrLen; i++){
                                        var member=memberList[i];
                                        var cdata=new Date(member.createtime);
                                        var url='javascript:void(0);';
                                        if(lv==1){
                                            url='${contextPath}/wx/member/inferiorChildList.htm?pid='+member.id;
                                        }
                                        result+='  <a href="'+url+'" class="weui_media_box weui_media_appmsg">'
                                            +'<div class="weui_media_hd weui-updown">'
                                            +'<img class="weui_media_appmsg_thumb lazyload" src="'+member.headimg+'" alt="" data-img="'+member.headimg+'">'
                                            +'</div>'
                                            +'<div class="weui_media_bd">'
                                            +'<h4 class="weui_media_title">'+member.nickname+'</h4>'
                                            +'<p class="weui_media_desc">'+formatDateTime(cdata)+'</p>'
                                            +'</div>'
                                            +'</a>';
                                    }
                                    $(".weui_panel_bd").append(result);
                                    // 每次数据加载完，必须重置
                                    me.resetload();
                                }
                            }
                        },
                        error: function(xhr, type){
                            //alert('Ajax error!');
                            // 即使加载出错，也得重置
                            me.resetload();
                        }
                    });
                    }, 500);
                }
            });
        });
    </script>

    <script>
       /* $(function(){
            $('#tab1').tab({defaultIndex:0,activeClass:"tab-green"});
        });*/

    </script>
</head>

<body ontouchstart>
    <div class="weui_tab " style="height:44px;" id="tab1"><!--tab-fixed添加顶部-->
        <div class="weui_navbar" style="height:44px;">
            <div class="weui_navbar_item   <#if lv??&&lv==1>tab-green</#if>" <#if lv??&&lv==2>onclick="javascript:location.href='${contextPath}/wx/member/inferiorList.htm?mid=${mid!}&lv=1'" </#if>>
                1级推广
            </div>
            <div class="weui_navbar_item <#if lv??&&lv==2>tab-green</#if>"  <#if lv??&&lv==1>onclick="javascript:location.href='${contextPath}/wx/member/inferiorList.htm?mid=${mid!}&lv=2'" </#if>>
                2级推广
            </div>
        </div>
    </div>

<div class="weui_panel weui_panel_access">
    <div class="weui_panel_bd weui-border-b">

    </div>
    <input type="hidden" id="mid" value="${mid!}">
    <input type="hidden" id="lv" value="${lv!}">
    <input type="hidden" id="pageNum" value="${pageNum!0}">
    <input type="hidden" id="pageSize" value="${pageSize!}">
    <input type="hidden" id="totalPage" value="${totalPage!1}">
</body>
<script type="text/javascript">
    function   formatDateTime(now)   {
        var   year=now.getFullYear();
        var   month=now.getMonth()+1;
        if(month<10){
            month="0"+month;
        }
        var   date=now.getDate();
        if(date<10){
            date="0"+date;
        }
        var   hour=now.getHours();
        if(hour<10){
            hour="0"+hour;
        }
        var   minute=now.getMinutes();
        if(minute<10){
            minute="0"+minute;
        }
        var   second=now.getSeconds();
        if(second<10){
            second="0"+second;
        }
        return   year+"-"+month+"-"+date+"   "+hour+":"+minute+":"+second;
    }

</script>
</html>